<template>
  <div class="content">
    <button @click="flag = !flag">switch</button>
    <!-- 
      通过appear属性可以设置节点对应的三个过渡状态
      但是只有初始化时生效
    -->
    <transition
      appear
      appear-from-class="from"
      appear-active-class="active"
      appear-to-class="to"
      >
      <div v-if="flag" class="box"></div>
    </transition>
    <transition
      appear
      appear-active-class="animate__animated animate__backOutDown"
      :duration="{ enter: 2000, leave: 5000 }"
      >
      <div v-if="flag" class="box"></div>
    </transition>
  </div>
</template>

<script setup lang="ts">
import { ref } from "vue"
import "animate.css"

const flag = ref<boolean>(true)


</script>

<style lang="scss" scoped>
  .box {
    width: 200px;
    height: 200px;
    background-color: red;
  }

  .from {
    width: 0;
    height: 0;
  }

  .active {
    transition: all 2s cubic-bezier(0.19, 1, 0.22, 1);
  }

  .to {
    width: 200px;
    height: 200px;
  }
</style>